<%#
 Copyright 2013-2018 the original author or authors from the JHipster project.

 This file is part of the JHipster project, see https://www.jhipster.tech/
 for more information.

 Licensed under the Apache License, Version 2.0 (the "License");
 you may not use this file except in compliance with the License.
 You may obtain a copy of the License at

      http://www.apache.org/licenses/LICENSE-2.0

 Unless required by applicable law or agreed to in writing, software
 distributed under the License is distributed on an "AS IS" BASIS,
 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 See the License for the specific language governing permissions and
 limitations under the License.
-%>
# ===================================================================
# Spring Boot configuration.
#
# This configuration will be overridden by the Spring profile you use,
# for example application-dev.yml if you use the "dev" profile.
#
# More information on profiles: https://www.jhipster.tech/profiles/
# More information on configuration properties: https://www.jhipster.tech/common-application-properties/
# ===================================================================

# ===================================================================
# Standard Spring Boot properties.
# Full reference is available at:
# http://docs.spring.io/spring-boot/docs/current/reference/html/common-application-properties.html
# ===================================================================

<%_ if (serviceDiscoveryType === 'eureka') { _%>
eureka:
    client:
        enabled: true
        healthcheck:
            enabled: true
        fetch-registry: true
        register-with-eureka: true
        instance-info-replication-interval-seconds: 10
        registry-fetch-interval-seconds: 10
    instance:
        appname: <%= baseName.toLowerCase() %>
        instanceId: <%= baseName.toLowerCase() %>:${spring.application.instance-id:${random.value}}
        lease-renewal-interval-in-seconds: 5
        lease-expiration-duration-in-seconds: 10
        status-page-url-path: ${management.endpoints.web.base-path}/info
        health-check-url-path: ${management.endpoints.web.base-path}/health
        metadata-map:
            zone: primary # This is needed for the load balancer
            profile: ${spring.profiles.active}
            version: ${info.project.version:}
            git-version: ${git.commit.id.describe:}
            git-commit: ${git.commit.id.abbrev:}
            git-branch: ${git.branch:}
ribbon:
    eureka:
        enabled: true
<%_ } _%>
<%_ if (applicationType === 'gateway' && serviceDiscoveryType) { _%>
# See http://cloud.spring.io/spring-cloud-netflix/spring-cloud-netflix.html
zuul: # those values must be configured depending on the application specific needs
    sensitive-headers: Cookie,Set-Cookie #see https://github.com/spring-cloud/spring-cloud-netflix/issues/3126
    host:
        max-total-connections: 1000
        max-per-route-connections: 100
    semaphore:
        max-semaphores: 500
    <%_ if (serviceDiscoveryType === 'consul') { _%>
    ignoredServices: 'consul,<%= baseName %>' # Prevent Consul and the "<%= baseName %>" app itself from having a Zuul route automatically created for them
    <%_ } _%>

# See https://github.com/Netflix/Hystrix/wiki/Configuration
hystrix:
    command:
        default:
            execution:
                isolation:
                    thread:
                        timeoutInMilliseconds: 10000

<%_ } _%>
<%_ if (applicationType === 'microservice') { _%>
feign:
    hystrix:
        enabled: true
#    client:
#        config:
#            default:
#                connectTimeout: 5000
#                readTimeout: 5000

# See https://github.com/Netflix/Hystrix/wiki/Configuration
hystrix:
    command:
        default:
            execution:
                isolation:
                    strategy: SEMAPHORE
# See https://github.com/spring-cloud/spring-cloud-netflix/issues/1330
#                    thread:
#                        timeoutInMilliseconds: 10000
    shareSecurityContext: true

<%_ } _%>
management:
    endpoints:
        web:
            base-path: /management
            exposure:
                include: ["configprops", "env", "health", "info", "threaddump", "logfile" ]
    endpoint:
        health:
            show-details: when_authorized
    info:
        git:
            mode: full
    health:
        mail:
            enabled: false # When using the MailService, configure an SMTP server and set this to true
    metrics:
        enabled: false # http://micrometer.io/ is disabled by default, as we use http://metrics.dropwizard.io/ instead

spring:
    <%_ if (searchEngine === 'elasticsearch') { _%>
    autoconfigure:
        exclude: <% if (databaseType === 'sql' && messageBroker === 'kafka') { %>org.springframework.boot.actuate.autoconfigure.metrics.jdbc.DataSourcePoolMetricsAutoConfiguration,<% } %>org.springframework.boot.autoconfigure.data.elasticsearch.ElasticsearchAutoConfiguration,org.springframework.boot.autoconfigure.data.elasticsearch.ElasticsearchDataAutoConfiguration
    <%_ } else if (databaseType === 'sql' && messageBroker === 'kafka') { _%>
    autoconfigure:
        exclude: org.springframework.boot.actuate.autoconfigure.metrics.jdbc.DataSourcePoolMetricsAutoConfiguration
    <%_ } _%>
    application:
        name: <%= baseName %>
    <%_ if (serviceDiscoveryType === 'consul') { _%>
    cloud:
        consul:
            discovery:
                healthCheckPath: /management/health
                instanceId: ${spring.application.name}:${spring.application.instance-id:${random.value}}
            config:
                watch:
                    enabled: false
    <%_ } _%>
    <%_ if (!serviceDiscoveryType) { _%>
    profiles:
        # The commented value for `active` can be replaced with valid Spring profiles to load.
        # Otherwise, it will be filled in by <%= buildTool %> when building the WAR file
        # Either way, it can be overridden by `--spring.profiles.active` value passed in the commandline or `-Dspring.profiles.active` set in `JAVA_OPTS`
        active: #spring.profiles.active#
    <%_ } _%>
    <%_ if (databaseType === 'sql') { _%>
    jpa:
        open-in-view: false
        properties:
            hibernate.jdbc.time_zone: UTC
        hibernate:
            ddl-auto: none
            naming:
                physical-strategy: org.springframework.boot.orm.jpa.hibernate.SpringPhysicalNamingStrategy
                implicit-strategy: org.springframework.boot.orm.jpa.hibernate.SpringImplicitNamingStrategy
    <%_ } _%>
    messages:
        basename: i18n/messages
    mvc:
        favicon:
            enabled: false
    thymeleaf:
        mode: HTML
<%_ if (authenticationType === 'oauth2') { _%>

# ===================================================================
# OpenID Connect Settings. Default settings are for Keycloak in Docker.
# Start Keycloak using `docker-compose -f src/main/docker/keycloak.yml up`.
#
# To use Okta, your settings should resemble the following:
#
# accessTokenUri: https://{yourOktaDomain}.com/oauth2/default/v1/token
# userAuthorizationUri: https://{yourOktaDomain}.com/oauth2/default/v1/authorize
# clientId: {copy after creating an OIDC app}
# clientSecret: {copy after creating an OIDC app}
# userInfoUri: https://{yourOktaDomain}.com/oauth2/default/v1/userinfo
# tokenInfoUri: https://{yourOktaDomain}.com/oauth2/default/v1/introspect
#
# You can also override these properties using environment variables.
# For example:
#
# export SECURITY_OAUTH2_CLIENT_CLIENT_ID="jhipster"
# export SECURITY_OAUTH2_CLIENT_CLIENT_SECRET="38561a05"
# ===================================================================
<%_ } _%>
<%_ if (authenticationType === 'uaa' || authenticationType === 'oauth2') { _%>
security:
<%_ } _%>
    <%_ if (authenticationType === 'uaa') { _%>
    oauth2:
        resource:
            filter-order: 3
    <%_ } _%>
    <%_ if (authenticationType === 'oauth2') {  _%>
    oauth2:
        client:
            <%_ if (applicationType === 'gateway' || applicationType === 'monolith') { _%>
            access-token-uri: http://localhost:9080/auth/realms/jhipster/protocol/openid-connect/token
            user-authorization-uri: http://localhost:9080/auth/realms/jhipster/protocol/openid-connect/auth
            client-id: web_app
            client-secret: web_app
            scope: openid profile email
            <%_ } _%>
            <%_ if (applicationType === 'microservice') { _%>
            client-id: internal
            client-secret: internal
            <%_ } _%>
        resource:
            user-info-uri: http://localhost:9080/auth/realms/jhipster/protocol/openid-connect/userinfo
    <%_ } _%>

server:
    servlet:
        <%_ if ((applicationType === 'microservice' || applicationType === 'uaa') && !serviceDiscoveryType) { _%>
        context-path: /${spring.application.name}
        <%_ } _%>
        session:
            cookie:
                http-only: true

# Properties to be exposed on the /info management endpoint
info:
    # Comma separated list of profiles that will trigger the ribbon to show
    display-ribbon-on-profiles: "dev"

# ===================================================================
# JHipster specific properties
#
# Full reference is available at: https://www.jhipster.tech/common-application-properties/
# ===================================================================

jhipster:
    async:
        core-pool-size: 2
        max-pool-size: 50
        queue-capacity: 10000
    # By default CORS is disabled. Uncomment to enable.
    #cors:
        #allowed-origins: "*"
        #allowed-methods: "*"
        #allowed-headers: "*"
        <%_ if (authenticationType === 'session') { _%>
        #exposed-headers: "Link,X-Total-Count"
        <%_ } else { _%>
        #exposed-headers: "Authorization,Link,X-Total-Count"
        <%_ } _%>
        #allow-credentials: true
        #max-age: 1800
    mail:
        from: <%= baseName %>@localhost
    swagger:
        default-include-pattern: /api/.*
        title: <%=baseName%> API
        description: <%=baseName%> API documentation
        version: 0.0.1
        terms-of-service-url:
        contact-name:
        contact-url:
        contact-email:
        license:
        license-url:

# ===================================================================
# Application specific properties
# Add your own application properties here, see the ApplicationProperties class
# to have type-safe configuration, like in the JHipsterProperties above
#
# More documentation is available at:
# https://www.jhipster.tech/common-application-properties/
# ===================================================================

# application:
